import { Vnode,vnode } from './vnode'
import { isEmpty } from './utils'

/**
 * sel 标签
 * d data
 * c children
 * 不支持 null 占位
 * **/
export function h(sel,d,c) {
  if(!sel){
    throw new Error('sel不能为空')
  }
  if(d != null){
    if(['string','boolean','number'].includes(typeof d)){
      return vnode(sel,null,null,d,null,null)
    }else if(Array.isArray(d) || d.constructor === Vnode){
      return vnode(sel,null,d,null,null,null)
    }else{
      if(c && ['string','boolean','number'].includes(typeof c)){
        return vnode(sel,d,null,c,d.key,null)
      }else if(Array.isArray(c) || c.constructor === Vnode){
        return vnode(sel,d,c,null,d.key,null)
      }
    }
  }


}
